//
//  FriendCell.m
//  Molian
//
//  Created by wansong on 4/7/15.
//  Copyright (c) 2015 xiaocan. All rights reserved.
//

#import "FriendCell.h"

@implementation FriendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat cellHeight = 50;
        
        self.accessoryType = UITableViewCellAccessoryNone;
            
        // 用户头像
        self.avatarImgView = [[UIImageView alloc]init];
        self.avatarImgView.frame = CGRectMake(10, (cellHeight-40)/2, 40, 40);
        self.avatarImgView.layer.masksToBounds = YES;//开启圆角
        [self.avatarImgView.layer setCornerRadius:5.0f];
        [self.avatarImgView setContentMode:UIViewContentModeScaleAspectFill];
        [self.contentView addSubview:self.avatarImgView];
        
        // 用户名字
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.frame = CGRectMake(60, 5, DeviceWidth-80, 20);
        self.nameLabel.font = [UIFont fontWithName:FontName size:15];
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.nameLabel];
        
        // 用户年龄
        self.ageLabel = [[UIButton alloc]init];
        self.ageLabel.frame = CGRectMake(60, ((cellHeight-40)/2)+28, 22, 12);
        self.ageLabel.titleLabel.font = [UIFont fontWithName:FontName size:11];
        [self.ageLabel.layer setCornerRadius:6];
        self.ageLabel.clipsToBounds = YES;
        self.ageLabel.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        self.ageLabel.contentEdgeInsets = UIEdgeInsetsMake(1, 0, 0, 0);
        [self.ageLabel setBackgroundImage:[UIImage imageNamed:@"boy_age"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.ageLabel];
        
        // 位置
        self.locationLabel = [[UILabel alloc]init];
        self.locationLabel.frame = CGRectMake(90, ((cellHeight-40)/2)+28, 90, 12);
        self.locationLabel.font = [UIFont fontWithName:FontName size:11];
        self.locationLabel.textAlignment = NSTextAlignmentLeft;
        self.locationLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.locationLabel];
        
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
